﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Baosight.ZNH.ZMCommon;
using Baosight.ZNH.ZMCommon.ChildWindows;
using Baosight.ZNH.ZMCommon.Prompt;
using Baosight.Platform.Core;

namespace Baosight.ZNH.ZP.UI.PopWindows
{
    public partial class AddResourcesGroup : EFViewCmes
    {
        public string Method = "add";
        public string title = "添加";
        public AddResourcesGroup()
        {
            InitializeComponent();
        }

                /// <summary>
        /// 确定按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CommitClick(object sender, RoutedEventArgs e)
        {
            TempButton = sender as Button;
            TempButton.IsEnabled = false;

            if (this.resGrid.CheckedEIRows.Count <= 0)
            {
                this.ValidateMessagePopup("请勾选要" + title + "的资源组！");
                TempButton.IsEnabled = true;
                return;
            }

            EIInfo info = new EIInfo();
            info.Set(EIConstants.ServiceNameKey, eServiceName);
            info.Set(EIConstants.MethodNameKey, Method);
            info.Set("roleId", this.roleId.Value);
            EIBlock block = info.AddBlock("result");
            block.SetColumns(this.resGrid.EIBlock.GetColumns());
            block.SetRows(this.resGrid.CheckedEIRows);
            this.Submit(info, DoCommitCompleted);
        }

        /// <summary>
        /// 取消按钮
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CancelClick(object sender, RoutedEventArgs e)
        {
            CmesWindows _window = this.Parent as CmesWindows;
            _window.DialogResult = false;
            _window.Close();
        }

        /// <summary>
        /// 消息提示
        /// </summary>
        public void ValidateMessagePopup(string msg)
        {
            Prompts pop = Prompts.getInstance();
            pop.SetMsg(msg);
            pop.Show(6);

            return;
        }

        /// <summary>
        /// 查询
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Query_Click(object sender, RoutedEventArgs e)
        {
            this.OnQueryButtonClick(sender, e);
        }
    }
}
